using System;
using CommandSystem;

namespace CustomItem.Commands.CustomItemCommands
{
    public class CustomItemCommand : ParentCommand, IUsageProvider
    {
        public CustomItemCommand() => LoadGeneratedCommands();
        
        public override string Command => "customitem";

        public override string[] Aliases => Array.Empty<string>();

        public override string Description => "给予玩家/生成一个自定义物品";

        public string[] Usage => new string[] { "give/spawn/list", "玩家ID", "物品类名" };

        public override void LoadGeneratedCommands()
        {
            this.RegisterCommand(new Give());
            this.RegisterCommand(new List());
            this.RegisterCommand(new Spawn());
        }

        protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender,
            out string response)
        {
            if (!sender.CheckPermission(PlayerPermissions.GivingItems))
            {
                response = "你没有权限使用此命令！";
                return false;
            }

            response = "用法: customitem <give/spawn/list> <玩家ID> <物品类名>";
            return false;
        }
    }
}